class DashboardController {
    def index = {
        if (!session.user){
            redirect(controller:'user', action:'login')
        }
        User user = User.find(session.user)
        if (!params.id)
            params.id = user.plans.get(user.plans.count()).id;
        Plan plan = Plan.get(params.id)
        
        [currentDate: new Date(), plan : plan]
    }

    def planList = {
        def currentPlan = Plan.get(params.id)
        User user = User.find(session.user)
        [currentPlan: currentPlan, plans: user.plans]
    }
}
